package com.kingyea.app.market.utils;

import com.alibaba.fastjson.JSON;
import com.google.common.collect.Maps;

import java.util.Map;

/**
 * @author cxc
 * @version v1.0.0
 * @description This is a class
 * @date Created in 2018.04.28 17:42
 */

public class JsonUtils {

    public static <T> T mapToBean(Map<Object, Object> map, Class<T> t) {
        return JSON.parseObject(JSON.toJSONString(map), t);
    }

    public static Map<String, Object> beanToMap(Object obj) {
        return JSON.parseObject(JSON.toJSONString(obj), Maps.<String, Object>newHashMap().getClass());
    }
}
